local xiedi = fk.CreateSkill{
    name = "lingling__xiedi",
}
Fk:loadTranslationTable{
    ["lingling__xiedi"] = "挟帝",
    [":lingling__xiedi"] = "回合结束时，你可以弃置一张牌并指定一名其他角色，直到你下回合开始，每当你受到伤害后，若其不为伤害来源，其弃置两张牌，不足则全弃并失去1点体力。",
    ["#lingling__xiedi"] = "挟帝：弃置一张牌并选择一名其他角色，你受到其以外角色造成的伤害时，令其弃置两张牌",
    ["@[chara]lingling__xiedi"] = "挟帝",
}
xiedi:addEffect(fk.TurnEnd,{
    anim_type = "control",
    can_trigger = function (self, event, target, player, data)
        return player == target and player:hasSkill(xiedi.name) and #player.room:getOtherPlayers(player) > 0
    end,
    on_cost = function (self, event, target, player, data)
        local room = player.room
        local targets = room:getOtherPlayers(player)
        local tos, cards, bool = room:askToChooseCardsAndPlayers(player,{
            max_card_num = 1,
            min_card_num = 1,
            max_num = 1,
            min_num = 1,
            pattern = ".",
            targets = targets,
            skill_name = xiedi.name,
            prompt = "#lingling__xiedi"
        })
        if #tos > 0 and #cards > 0 and bool then
            event:setCostData(self,{tos = tos, cards = cards})
            return true
        end
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local to = event:getCostData(self).tos[1]
        local cards = event:getCostData(self).cards
        room:throwCard(cards,xiedi.name,player)
        room:setPlayerMark(player,"@[chara]lingling__xiedi",to.id)
    end,
})
xiedi:addEffect(fk.Damaged,{
    anim_type = "control",
    is_delay_effect = true,
    can_trigger = function (self, event, target, player, data)
        if player:getMark("@[chara]lingling__xiedi") ~= 0 and target == player then
            local cp = player.room:getPlayerById(player:getMark("@[chara]lingling__xiedi"))
            return cp and cp:isAlive() and cp ~= data.from and not cp:isNude()
        end
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cp = room:getPlayerById(player:getMark("@[chara]lingling__xiedi"))
        if #cp:getCardIds("he") > 2 then
            room:askToDiscard(cp,{
                max_num = 2,
                min_num = 2,
                include_equip = true,
                cancelable = false,
                skill_name = xiedi.name
            })
        elseif cp:getCardIds("he") == 2 then
            room:throwCard(cp:getCardIds("he"),xiedi.name,cp)
        else
            room:throwCard(cp:getCardIds("he"),xiedi.name,cp)
            room:loseHp(cp,1,xiedi.name)
        end
    end,
})
xiedi:addEffect(fk.TurnStart,{
    can_refresh = function (self, event, target, player, data)
        return target == player and player:getMark("@[chara]lingling__xiedi") ~= 0
    end,
    on_refresh = function (self, event, target, player, data)
        player.room:setPlayerMark(player,"@[chara]lingling__xiedi",0)
    end,
})
return xiedi